package com.kefu.call.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kefu.basic.model.BasicStatusConfig;
import com.kefu.call.service.CallConfigStatusService;
import com.kefu.call.vo.CallStatusConfigInsertVo;
import com.kefu.call.vo.CallStatusConfigSearchVo;
import com.kefu.call.vo.CallStatusConfigUpdateVo;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DeleteVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "呼叫小休状态自定义")
@RestController
@RequestMapping("call/configStatus/")
public class CallConfigStatusController extends AbstractBaseController {
    @Resource
    private CallConfigStatusService callConfigStatusService;

    @PostMapping("add")
    @ApiOperation(value = "添加", notes = "添加")
    public Result<String> addCallStatusConfig(@Validated @RequestBody CallStatusConfigInsertVo callStatusConfigVo){
        callConfigStatusService.addStatusConfig(callStatusConfigVo);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("delete")
    @ApiOperation(value = "删除", notes = "删除")
    public Result<String> deleteCallStatusConfig(@Validated @RequestBody DeleteVo delete){
        callConfigStatusService.deleteStatusConfig(delete.getId());
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("update")
    @ApiOperation(value = "修改", notes = "修改")
    public Result<String> updateCallStatusConfig(@Validated @RequestBody CallStatusConfigUpdateVo update) {
        String result = callConfigStatusService.updateStatusConfig(update);
        return ResultGenerator.genSuccessResult(result);
    }

    @PostMapping("list")
    @ApiOperation(value = "列表", notes = "列表")
    public Result<Page<BasicStatusConfig>> listCallStatusConfig(@Validated @RequestBody CallStatusConfigSearchVo search){
        Page<BasicStatusConfig> page = callConfigStatusService.listStatusConfig(search);
        return ResultGenerator.genSuccessResult(page);
    }
}
